#include <unistd.h>
#include <stdlib.h>
#include <thread>
#include "ZDebug.h"

static void here(ZDebug* debug) {
    int n = 10;
    while (n > 0) {
        debug->log("in here %d\n", n);
        sleep(2);
        n -= 2;
    }
}

int main(int argc, char *argv[])
{
    if (argc < 3) {
        printf("usage: %s ip port\n", argv[0]);
        return -1;
    }

    ZDebug* debug = new ZDebug();
    if (0 == debug->init(argv[1], atoi(argv[2]))) {
        std::thread a(here, debug);
        int n = 10;
        while (n > 0) {
            debug->log("in main %d\n", n);
            sleep(1);
            --n;
        }
        a.join();
        delete debug;
        return 0;
    }
    return -1;
}
